package com.ymatou.iapi.productmanager.testcase.old;

import com.ymatou.iapi.productmanager.parameter.AddProductInLivesBean;
import com.ymatou.iapi.productmanager.parameter.UpdateLiveVideoProductSortBean;
import com.ymatou.iapi.productmanager.parameter.product.AddSellerProductRequest;
import com.ymatou.iapi.productmanager.service.AddProductInLivesCall;
import com.ymatou.iapi.productmanager.service.UpdateLiveVideoProductSortCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.LiveCallService;
import com.ymttest.business.service.ProductManagerCallServiceV2;
import com.ymttest.utils.EnvSetup;

import org.junit.*;
import org.junit.experimental.categories.Category;

import java.util.Arrays;
/**
*批量更新扫货现场视频商品排序
*FreeMaker Template自动生成代码
*/
@TestSuite
@Ignore
public class Ts_UpdateLiveVideoProductSort{
	private static UpdateLiveVideoProductSortBean updatelivevideoproductsortBean;
	private static UpdateLiveVideoProductSortCall updatelivevideoproductsortCall;
	private static Integer sellerId = Integer.valueOf(EnvSetup.getData("productsellerid"));
	private static String sellerName = EnvSetup.getData("productsellername");	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("批量更新扫货现场视频商品排序");
	}

	@Before
	public void caseUp() {
		updatelivevideoproductsortBean=new UpdateLiveVideoProductSortBean();
		updatelivevideoproductsortCall=new UpdateLiveVideoProductSortCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(updatelivevideoproductsortCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateLiveVideoProductSort_001() {
		Logger.start(true,"批量更新扫货现场视频商品排序");
		try {
			AddSellerProductRequest addProdReq =ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId1 = ProductManagerCallServiceV2.addNewProduct(addProdReq).get("Data").getAsJsonObject().get("ProductId").getAsString();
			String productId2 = ProductManagerCallServiceV2.addNewProduct(addProdReq).get("Data").getAsJsonObject().get("ProductId").getAsString();
			int liveId = LiveCallService.createLiveInProgress(sellerName, sellerId).getJSONObject("Data").getInt("ActivityId");
			AddProductInLivesBean addProductInLivesBean = new AddProductInLivesBean();
			addProductInLivesBean.setActivityId(liveId);
			addProductInLivesBean.setProductIds(Arrays.asList(productId1,productId2));
			addProductInLivesBean.setUserId(sellerId);
			AddProductInLivesCall addProductInLivesCall = new AddProductInLivesCall();
			addProductInLivesCall.setData(addProductInLivesBean);
			addProductInLivesCall.callService();
			updatelivevideoproductsortBean.setLiveId(liveId);
			updatelivevideoproductsortBean.setProductIdList(Arrays.asList(productId1,productId2));
			updatelivevideoproductsortCall.setData(updatelivevideoproductsortBean);
			updatelivevideoproductsortCall.callService();		
			Logger.verifyEquals("200", updatelivevideoproductsortCall.getString("Code"), "验证Code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}